<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<% 
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript" src="<%=basePath %>/resource/js/common-css-js.js" charset="UTF-8"></script>
</head>
<title>添加管理员用户</title>
</head>
<body>
<form class="layui-form">
  <div class="layui-form-item">
    <div class="layui-form-item">
      <input type="text" name="userName" required  lay-verify="required" placeholder="管理员用户名" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
      <div class="layui-form-item">
      	  <input id="newPassword" type="password" name="userPassword" required lay-verify="required" placeholder="管理员密码" autocomplete="off" class="layui-input">
      </div>
	  </div>
	  <div class="layui-form-item">
	      <input type="password" name="passwordToken" required lay-verify="required|passwordToken" placeholder="再次输入密码" autocomplete="off" class="layui-input">
	  </div>
	  <div class="layui-form-item">
	      <select id="role-list" name="userRole" lay-verify="required">
	      </select>
	  </div>
	  <div class="layui-form-item">
	      <select id="department-list" name="userDepartment" lay-verify="required">
	      </select>
	  </div>
	  <div class="layui-form-item">
	      <input type="text" name="useAuthor" required  lay-verify="required" placeholder="账号持有人" autocomplete="off" class="layui-input">
	  </div>
	  <div class="layui-form-item">
	      <input type="text" name="userLinkMethod" required  lay-verify="required|phone" placeholder="号主联系方式" autocomplete="off" class="layui-input">
	  </div>
	  <div class="layui-form-item layui-form-text">
	      <textarea name="userRemark" placeholder="请输入备注内容" class="layui-textarea"></textarea>
	  </div>
	  <%@include file="/admin/commonsPage/submit-reset.html" %>
</form>
<script type="text/javascript">
	$(function(){
		//获取当前页面中的select元素
		var roleElement = $("#role-list");
		var departmentElement = $("#department-list");
		//从父窗口中获取查询到的数据
		var role = parent.role;
		var department = parent.department;
		
		for(var item = 0;item<role.length;item++){
			roleElement.append("<option value='"+role[item].roleId+"'>"+role[item].roleName+"</option>")
		}
		for(var item = 0;item<department.length;item++){
			departmentElement.append("<option value='"+department[item].deptId+"'>"+department[item].deptName+"</option>")
		}
		form.render('select'); //刷新select选择框渲染
		requestAddData("/user");
	})
</script>
</body>
</html>